<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%
	int rsCount=(Integer)request.getAttribute("rsCount");
	int clientCount=(Integer)request.getAttribute("clientCount");
	int userCount=(Integer)request.getAttribute("userCount");

%>
<!DOCTYPE HTML>
<html>
<head>
<meta name="profile" content="active" />
</head>
<body>
	
	<div class="margin-bottom-15 padding-top-15">
		<div class="row">
			<div class="col-md-12">
				<ul class="nav nav-pills">
					<li class="active" style="margin: 0 20px 0 0;"><h1 style="margin: auto;line-height: 40px;">概况：  </h1></li>
					<li class="active" ><a href="views/resources.jsp">资源总数 <span
							class="badge"><%=rsCount%></span></a></li>
					<li class="active"><a href="views/clients.jsp">应用总数 <span
							class="badge"><%=clientCount%></span></a></li>
					<li class="active"><a href="views/users.jsp">用户总数 <span
							class="badge"><%=userCount%></span></a></li>
				</ul>
			</div>
		</div>
	</div>
	
	<div class="col-md-12 col-sm-12 margin-bottom-15 padding-top-15">
		<div class="panel panel-success">
			<div class="panel-heading">Orap</div>
			<div class="panel-body">
				Orap，OAuth2.0 Resources Authentication Platform
				是一个基于OAuth2.0的动态资源认证平台。<br>可以实现资源的动态注册及管理、应用的动态注册及管理、应用可请求的资源范围管理等功能。
			</div>
		</div>
	</div>
	
	<h1>使用步骤说明：</h1>
	
	<div class="col-md-12 col-sm-12 padding-top-15">
		<div class="panel-group" id="accordion">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseOne"> Step 1. </a>
					</h4>
				</div>
				<div id="collapseOne" class="panel-collapse collapse in">
					<div class="panel-body">
						<p><b>在资源管理中新建资源</b></p>
						<img width=100% src="images/createRS.jpg"></img>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseTwo"> Step 2. </a>
					</h4>
				</div>
				<div id="collapseTwo" class="panel-collapse collapse">
					<div class="panel-body">
						<p><b>在应用管理中新建应用</b></p>
						<img width=100% src="images/createApp.jpg"></img>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseThree"> Step 3. </a>
					</h4>
				</div>
				<div id="collapseThree" class="panel-collapse collapse">
					<div class="panel-body">
						<p><b>资源中验证access_token</b></p>
						
						<p>资源中需调用接口
						http://[OrapServer]/orap/oauth/check-token?access_token=&rsname=&scope=
						来验证应用请求传递来的access_token是否合法。
						access_token: 应用请求中附带的access_token
						rsname: 本资源在orap中注册的名称
						scope: 应该请求该资源内的具体url
						</p>
						<p>返回Http Status为200时表示access_token验证通过，非200是表示验证失败。资源内需根据返回进行不同处理。</p>
						
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseFour"> Step 4. </a>
					</h4>
				</div>
				<div id="collapseFour" class="panel-collapse collapse">
					<div class="panel-body">
						<p><b>获取access_token并请求资源</b></p>
						
						<p>在应用中以POST请求发送，注意设置Header的Content-Type为application/x-www-form-urlencoded
						<br>http://[OrapServer]/orap/oauth/token?client_id=[Client Id]&client_secret=[Client Secret]&grant_type=client_credentials
						将第二步中随机生成的Client Id和Client Secret作为参数。</p>
						
						<p>返回内容如下：
						{"token_type":"Bearer","expires_in":43199,"refresh_token":"f74a73a36f8a341dec1cb7d7c4ceb47e","access_token":"cf067af3b1f5d836e1718dd98332e256"}						
						然后应用就可以加上参数access_token直接访问资源url了。</p>
						
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>